package com.itguigu.rabbitmq.six;

import com.itguigu.rabbitmq.utils.RabbitMqutil;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * @Date 2021/7/18 21:14
 * @Created by wangle
 * @Description 发消息给交换机
 */
public class Directlogs {

    public static final String exchagenames = "direct_logs";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMqutil.getChannel();


        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {

            String messages = scanner.next();
            channel.basicPublish(exchagenames, "info", null, messages.getBytes(StandardCharsets.UTF_8));
            System.out.println("发出消息" + messages);
        }
    }

}
